// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sysin

import (
	"context"
	"github.com/gogf/gf/v2/encoding/gjson"
	"hotgo/internal/consts"
	"hotgo/internal/model/input/form"
	"hotgo/utility/validate"

	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/os/gtime"
)

// UserModuleListInp 获取用户模块列表
type UserModuleListInp struct {
	form.PageReq
	ID           int64  `json:"id"           dc:"用户ID"`
	Nickname     string `json:"nickname"     dc:"微信昵称"`
	Mobile       string `json:"mobile"       dc:"手机号"`
	RoleId       int64  `json:"roleId"       dc:"用户角色"`
	MemberStatus int    `json:"memberStatus" dc:"用户状态"`
	MemberType   int    `json:"memberType"   dc:"会员类型：1-月卡、2-季卡、3-年卡"`
	Label        string `json:"label"        dc:"用户标签"`
	Source       int    `json:"source"       dc:"渠道来源"`
}

func (in *UserModuleListInp) Filter(ctx context.Context) (err error) {
	return
}

type UserModuleListModel struct {
	Id             int64       `json:"id"           dc:"用户ID"`
	Avatar         string      `json:"avatar"       dc:"头像"`
	Nickname       string      `json:"nickname"     dc:"微信昵称"`
	RealName       string      `json:"realName"     dc:"绑定销氪"`
	ParentNickname string      `json:"parentNickname"     dc:"绑定用户昵称"`
	ParentRealName string      `json:"parentRealName"     dc:"绑定用户真实姓名"`
	Mobile         string      `json:"mobile"       dc:"手机号"`
	CreatedAt      *gtime.Time `json:"createdAt"    dc:"加入时间"`
	RoleId         int64       `json:"roleId"       dc:"用户角色"`
	MemberStatus   int         `json:"memberStatus" dc:"用户状态"`
	Label          *gjson.Json `json:"label"        dc:"用户标签"`
	Source         int         `json:"source"       dc:"渠道来源"`
	InviteCode     string      `json:"inviteCode"   dc:"邀请码"`
	Status         int         `json:"status"       dc:"状态"`
	MemberType     int         `json:"memberType"   dc:"会员类型：1-月卡、2-季卡、3-年卡"`
	ExpireTime     *gtime.Time `json:"expireTime"   dc:"到期时间"`
}

// UserModuleStatusInp 更新用户模块状态
type UserModuleStatusInp struct {
	Id     int64 `json:"id" v:"required#用户ID不能为空" dc:"用户ID"`
	Status int   `json:"status" dc:"状态"`
}

func (in *UserModuleStatusInp) Filter(ctx context.Context) (err error) {
	if in.Id <= 0 {
		err = gerror.New("用户ID不能为空")
		return
	}

	if in.Status <= 0 {
		err = gerror.New("状态不能为空")
		return
	}

	if !validate.InSlice(consts.StatusSlice, in.Status) {
		err = gerror.New("状态不正确")
		return
	}
	return
}

type UserModuleStatusModel struct{}
